package com.acane.instagram.controller;

import com.acane.instagram.pojo.Result;
import com.acane.instagram.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping()
    public Result login(@RequestParam("userName") String userName, @RequestParam("password") String password, HttpServletRequest request) {
        HttpSession httpSession = request.getSession();
        return loginService.login(userName, password, httpSession);
    }
}
